/*
 *    Copyright © OpenAtom Foundation.
 *
 *    Licensed under the Apache License, Version 2.0 (the "License");
 *    you may not use this file except in compliance with the License.
 *    You may obtain a copy of the License at
 *
 *         http://www.apache.org/licenses/LICENSE-2.0
 *
 *    Unless required by applicable law or agreed to in writing, software
 *    distributed under the License is distributed on an "AS IS" BASIS,
 *    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 *    See the License for the specific language governing permissions and
 *    limitations under the License.
 */

package com.inspur.edp.cef.variable.dtgenerator.api;


import com.inspur.edp.caf.generator.BaseGenerator;
import com.inspur.edp.cef.generator.apiGenerator.CefApiGenerator;
import com.inspur.edp.cef.generator.apiGenerator.CefApiGeneratorContext;
import com.inspur.edp.cef.generator.apiGenerator.dataType.mgrAllInterface.MgrAllInterfaceGenerator;
import com.inspur.edp.cef.generator.apiGenerator.dataType.mgrInterface.MgrInterfaceGenerator;
import com.inspur.edp.cef.generator.apiGenerator.dataType.mgrInterface.resourceInfo.ModelInfoBaseGenerator;
import com.inspur.edp.cef.variable.dtgenerator.VariableGeneratorContext;
import com.inspur.edp.cef.variable.dtgenerator.api.mginterface.VariableMgrInterfaceGenerator;
import com.inspur.edp.cef.variable.dtgenerator.api.mginterface.resinfo.VarModelInfoGenerator;
import com.inspur.edp.cef.variable.dtgenerator.api.mgrallinterface.VariableMgrAllInterfaceGenerator;
import com.inspur.edp.cef.variable.dtgenerator.api.variableinterface.VariableAllInterfaceGenerator;
import com.inspur.edp.cef.variable.dtgenerator.api.variableinterface.VariableInterfaceGenerator;

public class VariableApiGenerator extends CefApiGenerator
{
	protected VariableGeneratorContext variableGenContext;
	public VariableApiGenerator(VariableGeneratorContext variableGenContext)
	{
		super(variableGenContext);
		this.variableGenContext = variableGenContext;
	}

	private VariableApiGenContext getVariableApiGenContext(){return (VariableApiGenContext)super.getContext();}

	@Override
	protected CefApiGeneratorContext createCefApiGenContext()
	{
		VariableApiGenContext variableApiGenContext= new VariableApiGenContext(variableGenContext);
		variableApiGenContext.setNamespace(variableGenContext.getCommonVariableEntity().getGeneratedApiAssemblyInfo().getDefaultNamespace());
		return variableApiGenContext;
	}

	@Override
	protected MgrAllInterfaceGenerator getMgrAllInterfaceGenerator()
	{
		return new VariableMgrAllInterfaceGenerator(getVariableApiGenContext());
	}

	@Override
	protected MgrInterfaceGenerator getMgrInterfaceGenerator() {
		return new VariableMgrInterfaceGenerator(getVariableApiGenContext());
	}

	@Override
	protected ModelInfoBaseGenerator createModelInfoGenerator() {
		return new VarModelInfoGenerator(getVariableApiGenContext(), getVariableApiGenContext().getVariableGenCtx().getCommonVariableEntity());
	}

	@Override
	protected String getPackageName() {
		return getVariableApiGenContext().getNamespace();
	}

	@Override
	protected void beforeGenerate()
	{
		getVariableApiGenContext().setNamespace(variableGenContext.getCommonVariableEntity().getGeneratedApiAssemblyInfo().getDefaultNamespace());
		super.beforeGenerate();

		//Context.SetIsRef(true);
		//Context.SetRefProjectGen(variableGenContext.CefGeneratorContext.ApiGenContext);
	}

	@Override
	protected java.util.ArrayList<BaseGenerator> getExtendChildGenerators()
	{
	//C# TO JAVA CONVERTER TODO TASK: There is no equivalent to implicit typing in Java:
	java.util.ArrayList<BaseGenerator> childs = super.getExtendChildGenerators();
		if (childs == null)
	{
		childs = new java.util.ArrayList<BaseGenerator>();
	}
		childs.add(new VariableInterfaceGenerator(getVariableApiGenContext()));
		childs.add(new VariableAllInterfaceGenerator(getVariableApiGenContext()));
		return childs;
}
	@Override
	protected void doInitialize()
	{
		super.doInitialize();
	}
}
